<template>
  <div class="navbar nav navbg">
    <div class="MeetMe">
      <div><img :src="urlimg" alt="" class="img_title" /></div>
      Meng
    </div>
    <div class="nav_title">
      <div class="span" @click="clickNav1(0)">
        <span :class="{ textcolor: active == 0 }">Home</span>
      </div>
      <div class="span" @click="clickNav1(1)">
        <span :class="{ textcolor: active == 1 }">About</span>
      </div>
      <div class="span" @click="clickNav1(2)">
        <span :class="{ textcolor: active == 2 }">Skill</span>
      </div>
      <div class="span" @click="clickNav1(3)">
        <span :class="{ textcolor: active == 3 }">Share</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      urlimg: require("../assets/hg.jpeg"),
      active: "",
    };
  },

  methods: {
    clickNav1(index) {
      this.active = index;
      var PageId = document.querySelector("#anchor" + index);
      window.scrollTo({
        top: PageId.offsetTop,
        behavior: "smooth",
      });
    },
  },

  mounted() {},
  destroyed() {},
};
</script> 

<style lang='scss' scoped>
@media screen and (min-width: 800px) {
  .nav {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1030;
    width: 100%;
    height: 100px;
  }
  .navbar {
    padding: 0;
    height: 10%;
  }

  .active {
    color: #00b4d9;
    font-size: 1.4em;
  }
  .navbg {
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    //   padding: 20px 0px;
    font-weight: 700;
    line-height: 40px;
    cursor: pointer;
    //   background: transparent;
    .MeetMe {
      font-size: 2.3em;
      color: #00b4d9;
      width: 20%;
      display: flex;
      justify-content: center;
      align-items: center;
      .img_title {
        width: 45px;
        height: 45px;
        border-radius: 50%;
      }
    }
    .nav_title {
      width: 50%;
      display: flex;
    }
    .span {
      width: 300px;
      font-size: 1.3em;
      text-decoration: none;
      color: #333;
      .textcolor {
        color: #00b4d9;
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .nav {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1030;
    width: 100%;
    height: 100px;
  }
  .navbar {
    padding: 0;
    height: 10%;
  }

  .active {
    color: #00b4d9;
    font-size: 14px;
  }
  .navbg {
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    //   padding: 20px 0px;
    font-weight: 700;
    // line-height: 40px;
    cursor: pointer;
    //   background: transparent;
    .MeetMe {
      font-size: 20px;
      color: #00b4d9;
      width: 20%;
      display: flex;
      justify-content: center;
      align-items: center;
      .img_title {
        width: 30px;
        height: 30px;
        border-radius: 50%;
      }
    }
    .nav_title {
      width: 50%;
      display: flex;
    }
    .span {
      width: 100px;
      font-size: 14px;
      text-decoration: none;
      color: #333;
      .textcolor {
        color: #00b4d9;
      }
    }
  }
}
</style>